<div id="form"></div>
<script>
var grid;
var frm=$("#form").ajajform({
	header: "Редактирование категории в маркете",
	cssclass: "ajajform ajajformcenter",
	submit: {
		url: '{{action}}',
		value: "Сохранить",
		ajaj: true,
		params: {mode: "save",id: '{{fields.id}}',ajaj: 1}
	},
	footerButtons: [
		{value: "Добавить группу параметров",click: function() {cat_param_group_add();}},
		{value: "Добавить параметр",click: function() {cat_param_add();}},
		{value: "Удалить выбранные параметры",click: function() {cat_params_del();}}
	]
});
var columns=[
	{type:"textedit",name:"name",label:"Категория",width:600,value:{{JSON:item.name}}},
	{type:"select",name:"parent_id",label:"Родительская категория",width:600,value:{{JSON:item.parent_id}},values: {{JSON_select(1):parents}}},
	{type:"textareaedit",name:"abstract",label:"Врез",width:600,height:200,value:{{JSON:item.abstract}},wysiwyg:true},
	{type:"textareaedit",name:"description",label:"Описание",width:600,height:200,value:{{JSON:item.description}},wysiwyg:true},
	{type:"file_id",name:"image_id",label:"Картинка",width:600,value:{url: {{JSON:item.image_id_url}},name: {{JSON:item.image_id_name_or_filename}},id: {{JSON:item.image_id}} }},
	{type:"textedit",name:"seo_keywords",label:"SEO: keywords",width:600,value:{{JSON:item.seo_keywords}}},
	{type:"textedit",name:"seo_title",label:"SEO: title",width:600,value:{{JSON:item.seo_title}}},
	{type:"textedit",name:"seo_subject",label:"SEO: subject",width:600,value:{{JSON:item.seo_subject}}},
	{type:"textedit",name:"seo_description",label:"SEO: description",width:600,value:{{JSON:item.seo_description}}},
	{type:"checkbox",name:"enabled",label:"Вкл",width:600,value:{{JSON:item.enabled}}},
	{type:"label",name:"date_cr",label:"Дата создания",width:600,value:{{JSON:item.date_cr}}}
];
for (var i=0;i<columns.length;i++) {
	frm.ajajform("insertWidget",null,null,columns[i]);
}
grid=frm.ajajform("insertWidget",null,null,{
	type: "grid",
	title: "Парметры позиций в данной категории",
	name: "params",
	mode: "form-edit-full",
	rowSelection: true,
	rowClasses: [
		{
			name:"param",
			columns: [
				{name: "name",label:"Название",type:"text", width: 300},
				{name: "suffix",label:"Суффикс",type: "text", width: 70},
				{name: "show_short", label: "В кратком списке",type: "checkbox", width: 120},
				{name: "show_short_search", label: "В кратком поиске",type: "checkbox", width: 120},
				{name: "show_full_search", label: "В полном поиске",type: "checkbox", width: 120},
				{name: "datatype_id",label:"Тип данных",type:"select",width: 150,source:{{JSON_select(0):datatypes}}}
			]
		},
		{
			name:"group",
			cssclass: "market-param-group",
			columns: [
				{"name":"name","label":"Название","type":"text",width: 300},
				{"name":"none1","label":"","type":"none"},
				{"name":"none2","label":"","type":"none"},
				{"name":"none3","label":"","type":"none"},
				{"name":"none4","label":"","type":"none"},
				{"name":"none5","label":"","type":"none"}
			]
		}
	],
	rows: {{JSON:param_rows}}
});

function cat_param_group_add()
{
	grid.ajajform_grid("insertRow",null,{rowClass: "group",cells: [""]});
}

function cat_param_add()
{
	grid.ajajform_grid("insertRow",null,{rowClass: "param",cells: ["","",0,0,0,0],level:1});
}

</script>
